package com.yt.generator.factory;

import com.yt.generator.action.model.GenQo;
import com.yt.generator.utils.ToolUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 模板种类构建器
 *
 * @author fengshuonan
 * @date 2017-12-04-下午2:59
 */
public class DefaultTemplateFactory {

    /**
     * 获取所有的模板种类
     */
    public static List<Map<String, Object>> getDefaultTemplates() {
        ArrayList<Map<String, Object>> templates = new ArrayList<>();
        templates.add(create("entityDTOSwitch", "DTO-实体模板"));
        templates.add(create("entitySaveBOBOVOSwitch", "SaveBOBOVO-实体模板"));
        templates.add(create("controllerSwitch", "controller-控制器模板"));
        templates.add(create("serviceSwitch", "service-服务模板"));
        templates.add(create("mapperSwitch", "mapper-映射模板(mysql)"));
        templates.add(create("cmsFeignAndController", "cms feign和controller模板"));
        templates.add(create("apiFeignAndController", "api feign和controller模板"));
        templates.add(create("daoSwitch", "dao模板(mongodb)"));
        return templates;
    }

    /**
     * 获取默认的参数
     */
    public static GenQo getDefaultParams() {
        GenQo genQo = new GenQo();
        genQo.setProjectBasePath(ToolUtil.getWebRootBasePath(null));
        genQo.setPackageBaseName("com.cb");
        genQo.setAuthor("mxli");
        genQo.setIgnoreTablePrefix("sys_");
        genQo.setModuleName("learn");
        genQo.setParentMenuName("系统管理");
        return genQo;
    }

    private static Map<String, Object> create(String key, String desc) {
        HashMap<String, Object> template = new HashMap<>();
        template.put("key", key);
        template.put("desc", desc);
        return template;
    }
}
